package com.macro.mall.model;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

/**
 * cms_content实体类
 *
 * @author gaodx
 *
 */
@Data
public class CmsContent implements Serializable{
    /***/
    @ApiModelProperty(value = "")
    private Integer id;
    /**标题*/
    @NotBlank(message = "标题不可为空")
    @ApiModelProperty(value = "标题")
    private String title;
    /**1-图文 2-视频*/
    @NotBlank(message = "形式不可为空")
    @ApiModelProperty(value = "1-图文 2-视频")
    private String type;
    /**01-新闻 02-学习新闻*/
    @NotBlank(message = "类型不可为空")
    @ApiModelProperty(value = "01-新闻 02-学习新闻 03-通知栏 04-政策法规 05-社区通知 06-社区新闻 07-办事指南 08-其他（不在APP中展示） 10-弹窗")
    private String classified;
    @ApiModelProperty(value = "1-首页 2-社区 3-学院 4-学习 5-服务")
    private String popId;
    /**来源*/
    //@NotBlank(message = "来源不可为空")
    @ApiModelProperty(value = "来源")
    private String source;
    /**副标题*/
    @ApiModelProperty(value = "副标题")
    private String subtitle;
    /**内容*/
    @NotBlank(message = "内容不可为空")
    @ApiModelProperty(value = "内容")
    private String content;
    /**内容*/
    @ApiModelProperty(value = "电话号码")
    private String mobile;
    /**1-app 2-小程序  3-公众号*/
    @NotBlank(message = "渠道不可为空")
    @ApiModelProperty(value = "1-app 2-小程序  3-公众号")
    private String channel;
    /**视频地址*/
    @ApiModelProperty(value = "视频地址")
    private String videoUrl;
    /**生效时间*/
    @NotNull(message = "失效时间不可为空")
    @ApiModelProperty(value = "生效时间")
    private Date stime;
    /**失效时间*/
    @NotNull(message = "失效时间不可为空")
    @ApiModelProperty(value = "失效时间")
    private Date etime;
    /**审核状态 1-发布 2-审核中 3-审核不通过 4-审核通过 5-无效*/
    @ApiModelProperty(value = "审核状态 1-发布 2-审核中 3-审核不通过 4-审核通过 5-无效")
    private String status;
    /**审核失败原因*/
    @ApiModelProperty(value = "审核失败原因")
    private String reason;
    /**上次审核失败原因*/
    @ApiModelProperty(value = "上次审核失败原因")
    private String beforeReason;
    /**排序*/
    @ApiModelProperty(value = "排序")
    private String sort;
    @ApiModelProperty(value = "0-未推荐 1-推荐")
    private String isRecommend;
    @ApiModelProperty(value = "0-非预约 1-预约")
    private String isAppointment;
    /***/
    @ApiModelProperty(value = "")
    private Date createTime;
    /***/
    @ApiModelProperty(value = "")
    private Date updateTime;
    /**
     * 实例化
     */
    public CmsContent() {
        super();
    }
    /**
     * 实例化
     *
     * @param obj
     */

    public CmsContent(JSONObject obj) {
        this();
        if (obj.get("id") instanceof Number) {
            this.setId(((Number) obj.get("id")).intValue());
        }
        if (obj.get("title") instanceof String) {
            this.setTitle((String) obj.get("title"));
        }
        if (obj.get("type") instanceof String) {
            this.setType((String) obj.get("type"));
        }
        if (obj.get("classified") instanceof String) {
            this.setClassified((String) obj.get("classified"));
        }
        if (obj.get("popId") instanceof String) {
            this.setPopId((String) obj.get("popId"));
        }
        if (obj.get("source") instanceof String) {
            this.setSource((String) obj.get("source"));
        }
        if (obj.get("subtitle") instanceof String) {
            this.setSubtitle((String) obj.get("subtitle"));
        }
        if (obj.get("content") instanceof String) {
            this.setContent((String) obj.get("content"));
        }
        if (obj.get("channel") instanceof String) {
            this.setChannel((String) obj.get("channel"));
        }
        if (obj.get("videoUrl") instanceof String) {
            this.setVideoUrl((String) obj.get("videoUrl"));
        }
        this.setStime((Date) obj.get("stime"));
        this.setEtime((Date) obj.get("etime"));
        if (obj.get("status") instanceof String) {
            this.setStatus((String) obj.get("status"));
        }
        if (obj.get("reason") instanceof String) {
            this.setReason((String) obj.get("reason"));
        }
        if (obj.get("beforeReason") instanceof String) {
            this.setBeforeReason((String) obj.get("beforeReason"));
        }
        if (obj.get("sort") instanceof String) {
            this.setSort((String) obj.get("sort"));
        }
        this.setCreateTime((Date) obj.get("createTime"));
        this.setUpdateTime((Date) obj.get("updateTime"));
    }

    /**
     * 将当前对象转换为JsonObject
     *
     * @return
     */
    public JSONObject toJson() {
        JSONObject result = new JSONObject();
        if (this.getId() != null) {
            result.put("id",this.getId());
        }
        if (this.getTitle() != null) {
            result.put("title",this.getTitle());
        }
        if (this.getType() != null) {
            result.put("type",this.getType());
        }
        if (this.getClassified() != null) {
            result.put("classified",this.getClassified());
        }
        if (this.getPopId() != null) {
            result.put("popId",this.getPopId());
        }
        if (this.getSource() != null) {
            result.put("source",this.getSource());
        }
        if (this.getSubtitle() != null) {
            result.put("subtitle",this.getSubtitle());
        }
        if (this.getContent() != null) {
            result.put("content",this.getContent());
        }
        if (this.getChannel() != null) {
            result.put("channel",this.getChannel());
        }
        if (this.getVideoUrl() != null) {
            result.put("videoUrl",this.getVideoUrl());
        }
        if (this.getStime() != null) {
            result.put("stime",this.getStime());
        }
        if (this.getEtime() != null) {
            result.put("etime",this.getEtime());
        }
        if (this.getStatus() != null) {
            result.put("status",this.getStatus());
        }
        if (this.getReason() != null) {
            result.put("reason",this.getReason());
        }
        if (this.getBeforeReason() != null) {
            result.put("beforeReason",this.getBeforeReason());
        }
        if (this.getSort() != null) {
            result.put("sort",this.getSort());
        }
        if (this.getCreateTime() != null) {
            result.put("createTime",this.getCreateTime());
        }
        if (this.getUpdateTime() != null) {
            result.put("updateTime",this.getUpdateTime());
        }
        return result;
    }


    @Override
    public String toString() {
        return "CmsContent [id=" + id + " , title=" + title + " , type=" + type + " , classified=" + classified + " , popId=" + popId + " , source=" + source + " , subtitle=" + subtitle + " , content=" + content + " , channel=" + channel + " , videoUrl=" + videoUrl + " , stime=" + stime + " , etime=" + etime + " , status=" + status + " , reason=" + reason + " , beforeReason=" + beforeReason + " , sort=" + sort + " , createTime=" + createTime + " , updateTime=" + updateTime + "  ]";

    }


}
